﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ext.Net;
using Sharp.Portal.Mvc;
using Sharp.Portal.Mvc.Form;
using Sharp.WebBooter.Areas.Demo.Models;
using PartialViewResult = Ext.Net.MVC.PartialViewResult;
namespace Sharp.WebBooter.Areas.Demo.Controllers
{
    [AutomaticTemplate]
    public class LayoutController : Controller
    {

        public ActionResult Index(string containerId)
        {
            return new PartialViewResult
            {
                Model = new UserIndexViewModel()
                {
                    Layout = new Portal.Mvc.List.SharpList.LayoutInfo()
                    {
                        LayoutPath = "../Shared/_Layout.cshtml",
                        SectionName = "tabContent"
                    },
                    StoreUrlAction = "GetPaged,Tab"
                },
                ContainerId = containerId,
                RenderMode = RenderMode.AddTo
            };
        }

        public ActionResult Index2(string containerId)
        {
            var vm = new Tab2ViewModel();
            vm.UI.Layout = new SharpFrom.LayoutInfo()
            {
                LayoutPath = "../Shared/_Layout.cshtml",
                SectionName = "tabContent"
            };
            vm.UI.IsReadOnlyForm = true;
            vm.UI.RefreshUrl = Url.Action("GetData");


            return new PartialViewResult
            {
                Model = vm,
                ContainerId = containerId,
                RenderMode = RenderMode.AddTo
            };
        }

        public ActionResult GetData(string containerId, int? id)
        {
            var vm = new Tab2ViewModel();
            vm.UserName = containerId;
            vm.Comment = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
            vm.UI.IsReadOnlyForm = true;
            vm.UI.RefreshUrl = Url.Action("GetData");
            return new PartialViewResult
            {
                Model = vm,
                ContainerId = containerId,
                RenderMode = RenderMode.Replace
            };
        }
    }
}